<template>
	<view class="j_cont">
		<u-swipe-action :show="item.show" :index="index" v-for="(item, index) in list" :key="item.id"
			@click="click(item.id)" :options="options">
			<view class="item u-border-bottom">
				<view class="">
					<image mode="aspectFill" :src="item.hobbyurl" />
					<view class="j_images">
						<text>{{item.hobby}}</text>
					</view>
				</view>
				<!-- 此层wrap在此为必写的，否则可能会出现标题定位错误 -->
				<view class="title-wrap">
					<!-- top -->
					<view class="j_top">
						{{item.interest}}
					</view>
					<!-- cont -->
					<view class="j_Price" @open="opens(index)">
						<text></text>
						<view class="j_pings" @click="edit(item.id)">
							<text>编辑</text>
						</view>
					</view>
					<!-- bottom -->
					<view class="j_bottom">
						<text>开始时间</text>
						<text>{{item.time.slice(0,10)}}</text>
						<text>{{item.time.slice(11,16)}}</text>
					</view>
				</view>
			</view>
		</u-swipe-action>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				disabled: false,
				btnWidth: 180,
				show: undefined,
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#dd524d'
					}
				}]
			};
		},
		methods: {
			//跳转
			edit(id) {
				uni.navigateTo({
					url: `/pages/person/Discount/edit/edit?id=${id}`
				})
			},
			opens(index) {
				this.id.show = true
			},
			click(id) {
				this.$api.whjusers({
					id: id
				})

				this.$api.jHosdelMsg({
					id: id
				}).then(res => {
					this.$u.toast(`删除成功`);
					this.$api.WhjUser().then(res => {
						this.list = res.data.splice(13)
					})
				})

			}
		},
		onShow() {
			this.$api.WhjUser().then(res => {
				this.list = res.data.splice(13)
			})
		}
	};
</script>

<style lang="scss" scoped>
	.j_cont {
		width: 100%;
		height: 94vh;
		background: #F2F2F2;
		padding-top: 40upx;

		.j_images {
			text-align: center;
			margin-left: -30upx;
		}
	}

	.item {
		display: flex;
		padding: 20rpx;
	}

	image {
		width: 120rpx;
		flex: 0 0 120rpx;
		height: 120rpx;
		margin-right: 20rpx;
		border-radius: 12rpx;
	}

	.title-wrap {
		.j_top {
			width: 540upx;
			height: 40upx;
			font-size: 30upx;
			line-height: 40upx;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}

		.j_Price {
			width: 100%;
			height: 40upx;
			display: flex;
			justify-content: space-between;
			margin-top: 4upx;
			margin-bottom: 4upx;

			.j_pings {
				width: 120upx;
				height: 40upx;
				background: #FAAB34;
				border-radius: 10upx;
				text-align: center;
				line-height: 40upx;
				color: white;
				font-size: 16upx;
			}
		}

		//bottom
		.j_bottom {
			width: 100%;
			height: 40upx;
			line-height: 40upx;
			font-size: 20upx;

			text {
				margin-right: 20upx;
			}
		}
	}
</style>
